﻿<%@ Page Language="C#" MasterPageFile="~/Admin.master" Theme="Admin" AutoEventWireup="true"
    CodeFile="AManageProduct.aspx.cs" Inherits="Pages_AManageProduct" Title="Untitled Page" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="PageStyle">
        <div class="Content">
            <div class="HeaderStyle">
                <span class="Title1">Product's managent</span>
                <div class="HeadLine">
                </div>
            </div>
            <div class="FormStyle">
                <table cellpadding="0" cellspacing="0">
                    <tr>
                        <td>
                            Loại sản phẩm</td>
                        <td class="c1empty">
                        </td>
                        <td>
                            <asp:DropDownList ID="dlCate" runat="server">
                            </asp:DropDownList></td>
                        <td style="width:40px">
                        </td>
                        <td>
                            Trạng thái</td>
                        <td class="c1empty">
                        </td>
                        <td>
                            <asp:DropDownList ID="dlStatus" runat="server">
                                <asp:ListItem Text="All" Value="ALL"></asp:ListItem>
                                <asp:ListItem Text="Enable" Value="Enable"></asp:ListItem>
                                <asp:ListItem Text="Disable" Value="Disable"></asp:ListItem>
                            </asp:DropDownList></td>
                            
                    </tr>
                    <tr class="r1empty">
                        <td colspan="7">
                        </td>
                    </tr>
                    <tr>
                        <td colspan="7" class="ButtonStyle">
                            <asp:Button ID="btFilter" Text="Filter" runat="server" OnClick="btFilter_Click" /></td>
                    </tr>
                </table>
                <div class="r1empty">
                </div>
                <asp:GridView ID="gv" GridLines="None" runat="server" AutoGenerateColumns="False"
                    DataKeyNames="ProID" CellPadding="0" AllowPaging="True" CssClass="GridStyle"
                    AllowSorting="True" DataSourceID="odsCate" 
                    onrowdatabound="gv_RowDataBound">
                    <Columns>
                        <asp:TemplateField>
                            <HeaderTemplate>
                                <input id="ckLeader" type="checkbox" runat="server" class="ckLeader" />
                            </HeaderTemplate>
                            <ItemTemplate>
                                <input id="ckMember" type="checkbox" runat="server" class="ckMember" />
                            </ItemTemplate>
                            <ItemStyle CssClass="RowCell" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="HeaderCell" Width="20px" HorizontalAlign="Center" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Code">
                            <ItemTemplate>
                                <%# Eval("Model")%>
                            </ItemTemplate>
                            <ItemStyle CssClass="RowCell" />
                            <HeaderStyle CssClass="HeaderCell" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="T&#234;n">
                            <ItemTemplate>
                                <%# Eval("TEN") %>
                            </ItemTemplate>
                            <ItemStyle CssClass="RowCell" />
                            <HeaderStyle CssClass="HeaderCell" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Gi&#225;">
                            <ItemTemplate>
                                <%# int.Parse(Eval("GIA").ToString()).ToString("$#,#", myInfo) %>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Right" CssClass="RowCell" />
                            <HeaderStyle CssClass="HeaderCell" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Loại">
                            <ItemTemplate>
                                <%# Eval("LOAI") %>
                            </ItemTemplate>
                            <ItemStyle CssClass="RowCell" />
                            <HeaderStyle CssClass="HeaderCell" />
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Trạng th&#225;i">
                            <ItemTemplate>
                                <asp:Label ID="lbHinh" runat="server" Visible="false" Text='<%# Eval("Hinh") %>'></asp:Label>
                                <asp:Label ID="lbStatus" runat="server" Visible="false" Text='<%# Eval("TRANGTHAI") %>'></asp:Label>
                               <asp:Image ID="imgHinh" Width="16" Height="16" runat="server" src="../App_Themes/Admin/img/isimage.png"/><asp:Image ID="imgStatus" Width="16" Height="16" runat="server" src="../App_Themes/Admin/img/isenable.png" />
                            </ItemTemplate>
                            <ItemStyle CssClass="RowCell" HorizontalAlign="Center" />
                            <HeaderStyle CssClass="HeaderCell" />
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:HyperLink ID="btEdit" Text="Edit" runat="server" NavigateUrl='<%# "AEditProduct.aspx?pid="+ Eval("ProID").ToString()+"&pin="+ gv.PageIndex+ "&cty=" + dlCate.SelectedValue + "&sts=" + dlStatus.SelectedValue %>'></asp:HyperLink>
                            </ItemTemplate>
                            <ItemStyle HorizontalAlign="Center" CssClass="RowCell" />
                            <HeaderStyle CssClass="HeaderCell" Width="100px" />
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle CssClass="GridRow" />
                    <AlternatingRowStyle CssClass="GridAltRow" />
                    <HeaderStyle CssClass="GridHeader" />
                    <FooterStyle CssClass="GridFooter" />
                    <PagerStyle CssClass="GridPager" />
                </asp:GridView>
                <asp:ObjectDataSource ID="odsCate" runat="server" SelectMethod="filterProducts" TypeName="Jewelry.BussinessLayer.ProductBLL"
                    OnObjectCreating="odsCreating" OnSelected="odsSelected" 
                    OnSelecting="odsSelecting" EnablePaging="True" SelectCountMethod="getRowsCount">
                    <SelectParameters>
                        <asp:Parameter Name="strCate" ConvertEmptyStringToNull="false" Type="String" />
                        <asp:Parameter Name="listFeature" ConvertEmptyStringToNull="false" Type="Object" />
                        <asp:Parameter Name="strStatus" ConvertEmptyStringToNull="false" Type="String" />
                        <asp:Parameter Name="maximumRows" Type="Int32" />
                        <asp:Parameter Name="startRowIndex" Type="Int32" />
                    </SelectParameters>
                </asp:ObjectDataSource>
                <asp:CustomValidator ID="cval" runat="server" ValidationGroup="cate" Display="Dynamic"></asp:CustomValidator>
                <div class="r1empty">
                </div>
                <div class="ButtonStyle">
                    <asp:Button ID="btAddNew" runat="server" Text="Add new" OnClick="clickAdd" />
                    <asp:Button ID="btEnable" runat="server" Text="Enable" OnClick="clickEnable" OnClientClick="javascript:return confirmEnable()" />
                    <asp:Button ID="btDisable" runat="server" Text="Disable" OnClick="clickDisable" OnClientClick="javascript:return confirmDisable()" />
                </div>
            </div>
            <div class="FooterStyle">
            </div>
        </div>
    </div>

    <script type="text/javascript">
        $(document).ready(function(){
            $("#<%= gv.ClientID %>").checkall({
                leaderClass: 'ckLeader',
		        memberClass: 'ckMember'
            });
        });
        function confirmEnable()
        {
            var conf = confirm("Bạn có muốn enable những sản phẩm đã chọn?");
            return conf;
        }
        
        function confirmDisable()
        {
            var conf = confirm("Bạn có muốn disable những sản phẩm đã chọn?");
            return conf;
        }
    </script>

</asp:Content>
